home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_kdelibs.idb / usr / freeware / kde / include / krootprop.h.z / krootprop.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  4.8 KB  |  176 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1997 Mark Donohoe (donohoe@kde.org)
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.     Boston, MA 02111-1307, USA.
  18. */
  19. #ifndef _KROOTPROP_H
  20. #define _KROOTPROP_H_
  21.  
  22. #include <kapp.h>
  23.  
  24. #include <X11/Xlib.h>
  25. #include <X11/Xatom.h>
  26.  
  27. #include <qdict.h>
  28.  
  29. /** 
  30. * KDE desktop resources stored on the root window.
  31. *
  32. * A companion to the KConfig class
  33. *
  34. * The KRootProp class is used for reading and writing configuration entries
  35. * to properties on the root window.
  36. *
  37. * All configuration entries are of the form "key=value".
  38. *
  39. * @see KConfig::KConfig
  40. * @author Mark Donohoe (donohe@kde.org)
  41. * @version 
  42. * @short KDE Configuration Management class
  43. */
  44. class KRootProp
  45. {
  46. private:    
  47.   Display *kde_display;
  48.   Window root;
  49.   int screen;
  50.   Atom at;
  51.   QDict <QString> propDict;
  52.  
  53. protected:
  54.  
  55. public:
  56. /** 
  57. * Construct a KRootProp object. 
  58. *
  59. */
  60.    KRootProp();
  61.    
  62. /** 
  63. * Destructor. 
  64. *
  65. * Writes back any dirty configuration entries.
  66. */
  67.   ~KRootProp();
  68.  
  69. /** 
  70. * Specify the property in which keys will be searched.
  71. *
  72. */    
  73.   void setProp(const QString& rProp="");
  74.  
  75. /**
  76. * Read the value of an entry specified by rKey in the current property
  77. *
  78. * @param rKey    The key to search for.
  79. * @param pDefault A default value returned if the key was not found.
  80. * @return The value for this key or an empty string if no value
  81. *      was found.
  82. */    
  83.   QString readEntry( const QString& rKey, 
  84.                                 const char* pDefault = 0 ) const ;
  85.                       
  86. /**
  87. * Read a numerical value. 
  88. *
  89. * Read the value of an entry specified by rKey in the current property 
  90. * and interpret it numerically.
  91. *
  92. * @param rKey The key to search for.
  93. * @param nDefault A default value returned if the key was not found.
  94. * @return The value for this key or 0 if no value was found.
  95. */
  96.   int readNumEntry( const QString& rKey, int nDefault = 0 ) const;
  97.   
  98. /** 
  99. * Read a QFont.
  100. *
  101. * Read the value of an entry specified by rKey in the current property 
  102. * and interpret it as a font object.
  103. *
  104. * @param rKey        The key to search for.
  105. * @param pDefault    A default value returned if the key was not found.
  106. * @return The value for this key or a default font if no value was found.
  107. */ 
  108.   QFont readFontEntry( const QString& rKey, 
  109.                               const QFont* pDefault = 0 ) const;
  110.  
  111. /** 
  112. * Read a QColor.
  113. *
  114. * Read the value of an entry specified by rKey in the current property 
  115. * and interpret it as a color.
  116. *
  117. * @param rKey        The key to search for.
  118. * @param pDefault    A default value returned if the key was not found.
  119. * @return The value for this key or a default color if no value
  120. * was found.
  121. */                      
  122.   QColor readColorEntry( const QString& rKey,
  123.                                 const QColor* pDefault = 0 ) const;
  124.                               
  125.     
  126. /** 
  127. * writeEntry() overridden to accept a const char * argument.
  128. *
  129. * This is stored to the current property when destroying the
  130. * config object or when calling Sync().
  131. *
  132. * @param rKey        The key to write.
  133. * @param rValue        The value to write.
  134. * @return The old value for this key. If this key did not exist, 
  135. *      a null string is returned.      
  136. *
  137. * @see #writeEntry
  138. */                
  139.   QString writeEntry( const QString& rKey, const QString& rValue );
  140.   
  141. /** Write the key value pair.
  142. * Same as above, but write a numerical value.
  143. * @param rKey The key to write.
  144. * @param nValue The value to write.
  145. * @return The old value for this key. If this key did not
  146. * exist, a null string is returned.      
  147. */
  148.   QString writeEntry( const QString& rKey, int nValue );
  149.   
  150. /** Write the key value pair.
  151. * Same as above, but write a font
  152. * @param rKey The key to write.
  153. * @param rValue The value to write.
  154. * @return The old value for this key. If this key did not
  155. * exist, a null string is returned.      
  156. */
  157.   QString writeEntry( const QString& rKey, const QFont& rFont );
  158.   
  159. /** Write the key value pair.
  160. * Same as above, but write a color
  161. * @param rKey The key to write.
  162. * @param rValue The value to write.
  163. * @return The old value for this key. If this key did not
  164. *  exist, a null string is returned.      
  165. */
  166.   QString writeEntry( const QString& rKey, const QColor& rColor );
  167.  
  168. /** Flush the entry cache.
  169. * Write back dirty configuration entries to the current property,
  170. *  This is called automatically from the destructor.
  171. */    
  172.     void sync();
  173. };
  174.  
  175. #endif
  176.